home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2815 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  646 b 

  1. Path: news.islandnet.com!usenet
  2. From: jklinke@islandnet.com (Jason Klinke)
  3. Newsgroups: comp.lang.c
  4. Subject: Loop Invariant
  5. Date: 24 Jan 1996 01:42:08 GMT
  6. Organization: Digital Reality Inc.
  7. Message-ID: <4e42pg$2oq@sanjuan.islandnet.com>
  8. Reply-To: jklinke@uvaix.uvic.ca
  9. NNTP-Posting-Host: protection.islandnet.com
  10. X-Newsreader: WinVN 0.92.2
  11.  
  12. I'm having difficulty coming up with a loop invariant that I can prove, for
  13. the following code which computes the sum of the integers in the array 
  14. A[0..n-1] :
  15.  
  16. -----------
  17. sum = 0;
  18. for (i = 0; i < n; i++)
  19.     sum = sum + A[i];
  20. -----------
  21.  
  22. Any help with this invariant and its proof is appreciated.
  23.  
  24. Jason.
  25.  
  26.